<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登录</title>
    <link rel="stylesheet" type="text/css" href="./css/element-plus.index.css">
    <link rel="stylesheet" href="css/login.css">
    <script type="text/javascript" src="./js/vue.global.3.2.39.js"></script>
    <script type="text/javascript" src="./js/element-plus.2.2.15.js"></script>
    <script type="text/javascript" src="./js/element_plus_icons.2.0.9.js"></script>
    <script type="text/javascript" src="./js/axios.min.0.24.0.js"></script>
    <style>
        .el-form-item__error{
            color:yellow;
        }
    </style>
</head>
<body>
<div id="app">

    <div style="margin-top: 20%;margin-left: 30%">
        <el-form status-icon label-width="120px" ref="loginForm"  :model="userInfo">
            <el-form-item label="确认账号:" prop="pwd">
                <el-input autocomplete="off" style="width: 200px;" v-model="userInfo.userId"/>
            </el-form-item>
            <el-form-item label="新密码:" prop="pwd">
                <el-input autocomplete="off" style="width: 200px;" v-model="userInfo.pwd"/>
            </el-form-item>
            <el-form-item label="" prop="pwd">
                <div style="width: 200px;">
                    <el-button  type="primary" @click="updatePwd" >确认修改</el-button>
                </div>
            </el-form-item>
        </el-form>
    </div>

</div>
<script src="js/common.js"></script>
<script type="text/javascript">
    const options = {
        data() {
            return {
                userInfo:{
                    userId: null,
                    pwd: null,
                },
            };
        },
        methods: {
            updatePwd() {
                this.$refs['loginForm'].validate(valid=>{
                    if(valid){
                        //发送请求
                        axios.post('/user/updatePwd',this.userInfo).then(resp=>{
                            if(resp){
                                alert("密码修改成功");
                            }
                        });
                    }
                });
            },
            refreshCode(){

            }
        }
    };
    const app = Vue.createApp(options);
    app.use(ElementPlus);
    for (const [iconName, iconComp] of Object.entries(ElementPlusIconsVue)) {
        if (iconName == 'Menu') {
            app.component('IconMenu', iconComp);
        } else {
            app.component(iconName, iconComp);
        }
    }
    const vm = app.mount("#app");
</script>
</body>
</html>